//------------------------------------------------------------------------------ 
//      Copyright (c) 2004-2007, Be Nanashi-San 
// 
//      Permission is hereby granted, free of charge, to any person obtaining a 
//      copy of this software and associated documentation files (the "Software"), 
//      to deal in the Software without restriction, including without limitation 
//      the rights to use, copy, modify, merge, publish, distribute, sublicense, 
//      and/or sell copies of the Software, and to permit persons to whom the 
//      Software is furnished to do so, subject to the following conditions: 
// 
//      The above copyright notice and this permission notice shall be included in 
//      all copies or substantial portions of the Software. 
// 
//      THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
//      IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
//      FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
//      AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
//      LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
//      FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
//      DEALINGS IN THE SOFTWARE. 
// 
//      File Name:	Util.h
//      Author: 	Be Nanashi-San 
//      Description:	 
//------------------------------------------------------------------------------
#ifndef UTIL_H_INCLUDED
#define UTIL_H_INCLUDED

// mwcc and ppc
#if defined(__POWERPC__) && defined(__MWERKS__)
	#define ABS(n) __abs(n)
#else
	#define ABS(n) (0 < n) ? n : -n
#endif

class BDirectory;
class BPositionIO;
class BMenuItem;
class BHandler;
class BString;
class BButton;
class BView;
class BRadioButton;
class BRect;
class BCheckBox;

//GUI Utils
BMenuItem * MakeItem(BHandler *target, const char * label, uint32 command, char shortcut = 0, uint32 modifiers = 0);
BMenuItem * MakeItem(BHandler *target, const char * label, uint32 command, const char *text);
BMenuItem * MakeItem(BHandler *target, const char * label, uint32 command, BString &text);
BButton* MakeButton(BRect r, const char *label, uint32 command, BView *view, bool b = true);
BRadioButton * MakeRadioButton(BRect r,  const char *name, const char *label, uint32 command, BView *view);
BCheckBox * MakeCheckBox(BRect r,  const char *name, const char *label, uint32 command, BView *view);

void ClearBBSCache();
void findcachedir(BDirectory *cachedir, const char *dir, const char *uri = NULL);
void cutf8(BPositionIO *in, BPositionIO *out);
void Launcher(const char *type, const char *param);

#endif //UTIL_H_INCLUDED
